-
Notifications
You must be signed in to change notification settings - Fork 7
PCSM-219: Align all env var config with CLI and HTTP request options #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add github.com/spf13/viper to go.mod - Create config/config.go with Init() function - Bind env vars for global options only (not clone tuning) PCSM-219: Integrate Viper with Cobra for logging and server options - Call config.Init() in PersistentPreRun - Use Viper for log-level, log-json, no-color flags - Use Viper for source/target URIs and port - Simplify getPort() to use Viper with env var fallback
- Add --mongodb-cli-operation-timeout persistent flag (NOT hidden) - Update MongoDBOperationTimeout() to use Viper - Add deprecated alias OperationMongoDBCliTimeout() for backward compat
- Add --use-collection-bulk-write hidden persistent flag - Update UseCollectionBulkWrite() to use Viper - Env var PCSM_USE_COLLECTION_BULK_WRITE still supported
- Add --clone-num-parallel-collections hidden flag - Add --clone-num-read-workers hidden flag - Add --clone-num-insert-workers hidden flag - Add --clone-segment-size hidden flag - Add --clone-read-batch-size hidden flag - All clone tuning options use Viper (CLI only, no env var support)
- Add github.com/go-playground/validator/v10 dependency - Create validate/validate.go with singleton validator - Create validate/errors.go with error types and translation - Create validate/bytesize.go with custom byte size validators
- Extend pcsm.StartOptions with clone tuning fields - Update startRequest with clone tuning fields and validation tags - Add Validate() method to startRequest - Add resolveStartOptions() to merge HTTP/CLI/config values - Add resolveCloneSegmentSize/resolveCloneReadBatchSize helpers - HTTP values take precedence over CLI values
- Add --mongodb-cli-operation-timeout to PCSM Options - Update Environment Variables section with table format - Add Clone Tuning Options section with CLI/HTTP parameters - Update HTTP API /start with clone tuning parameters documentation
- Make --port a persistent flag (inherited by all subcommands) - Remove duplicate port flag definitions from subcommands - Simplify getPort() to use Viper directly (handles CLI > env var > default) - Remove unused pflag import
- Add configuration reference table to config/config.go (single source of truth) - Remove redundant config source comments from config/values.go - Remove references to external decision documents - Simplify function comments to describe behavior, not configuration
- Replace decision references with self-documenting comments - Comments now describe what/why, not where it was decided
- Remove getPort() wrapper, use viper.GetInt("port") directly
- Remove unused GetString, GetInt, GetBool, IsSet wrappers from config/config.go
- These wrappers added no value (pure pass-through with no added logic)
PCSM-219: Update VSCode settings and README with additional config options PCSM-219: Fix
chupe
commented
Dec 29, 2025
a6eb1af to
1721b17
Compare
inelpandzic
reviewed
Dec 30, 2025
- Add env var bindings: PCSM_PORT, PCSM_LOG_LEVEL, PCSM_LOG_JSON, PCSM_NO_COLOR - Remove --use-collection-bulk-write CLI flag (env var only) - Hide clone-segment-size and clone-read-batch-size flags - Remove help text from hidden flags
inelpandzic
reviewed
Jan 7, 2026
Collaborator
inelpandzic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left couple of comments, please check them out, but overall I'm really really happy how this turned out!
inelpandzic
reviewed
Jan 7, 2026
inelpandzic
reviewed
Jan 8, 2026
inelpandzic
approved these changes
Jan 8, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Configuration handling was inconsistent across input sources. Environment variables, CLI flags, and HTTP request parameters lacked unified processing, making it difficult to reason about option precedence and validate inputs consistently. There were no integration tests for the CLI client subcommands.
Solution
Introduced Viper with mapstructure for unified configuration loading via a new config/ package with structured types (Config, MongoDBConfig, CloneConfig). Moved validation logic from main.go to config.Validate() for testability and consistent enforcement across all input sources.
Added CLI integration tests that build the binary once in TestMain and run it as a subprocess against a mock HTTP server. Tests cover all client subcommands (start, status, finalize, pause, resume) with their respective flags and verify port configuration via --port flag and PCSM_PORT env var.
Also added:
An overview of how these changes affect the UX is summarized by @inelpandzic here as a post-hoc specification for the changes.